#include <stdio.h>
#include <string.h>

//将数字转换成响应的字符串
const char* changeToCh(char number){
	switch(number){
		case '0':
			return "ling";
		case '1':
			return "yi";
		case '2':
			return "er";
		case '3':
			return "san";
		case '4':
			return "si";
		case '5':
			return "wu";
		case '6':
			return "liu";
		case '7':
			return "qi";
		case '8':
			return "ba";
		case '9':
			return "jiu";
		default:
			return NULL;
	}
}
int main()
{
	char str[2048] = {0};
	int sum = 0;
	int i = 0;
	printf("请输入一个自然数: ");
	scanf("%s", &str);
	printf("输入的数字为: %s\n", str);
	//计算求得数字之和
	for(i = 0; i < strlen(str); i++){
		sum += (str[i] - '0');
	}
	printf("sum = %d\n", sum);
	//清空字符串
	memset(str, 0, sizeof(str));
	//将数字之和转换成字符串,并输出每个位置上的响应拼音
	sprintf(str, "%d", sum);
	for(i = 0; i < strlen(str) - 1; i++){
		printf("%s ", changeToCh(str[i]));
	}
	printf("%s\n", changeToCh(str[i]));
	return 0;
}
